package com.mycompany.app.common.scheduler.quartz;

import java.lang.reflect.InvocationTargetException;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.util.Assert;
import org.springframework.util.MethodInvoker;

public class DaemonJobExecutor implements Job {
    protected final static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
            .getLog(DaemonJobExecutor.class);

    public void execute(JobExecutionContext arg0) throws JobExecutionException {

        MethodInvoker invoker = QuartzUtils.getDaemonJobImpl("mailSenderJob");

        Assert.notNull(invoker);

        try {
            invoker.prepare();
            invoker.invoke();
        } catch (InvocationTargetException e) {
            log.error(e);
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            log.error(e);
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }

    }

}
